package com.anyou.mall.goo.goods.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.anyou.common.annotation.Log;
import com.anyou.common.core.controller.BaseController;
import com.anyou.common.core.domain.ApiResult;
import com.anyou.common.enums.BusinessType;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import com.anyou.mall.goo.goods.domain.LiGoodsSku;
import com.anyou.mall.goo.goods.service.ILiGoodsSkuService;
import com.anyou.common.utils.poi.ExcelUtil;
import com.anyou.common.core.page.TableDataInfo;

/**
 * goodSkuController
 *
 * @author ruoyi
 * @date 2023-09-16
 */
@Api(tags = "goodSku")
@RestController
@RequestMapping("/sku/goodSku")
public class LiGoodsSkuController extends BaseController
{
    @Autowired
    private ILiGoodsSkuService liGoodsSkuService;

    /**
     * 查询goodSku列表
     */
    @ApiOperation("查询goodSku列表")
    @PreAuthorize("@ss.hasPermi('sku:goodSku:list')")
    @GetMapping("/list")
    public TableDataInfo<List<LiGoodsSku>> list(LiGoodsSku liGoodsSku)
    {
        startPage();
        List<LiGoodsSku> list = liGoodsSkuService.selectLiGoodsSkuList(liGoodsSku);
        return getDataTable(list);
    }

    /**
     * 导出goodSku列表
     */
    @ApiOperation("导出goodSku列表")
    @PreAuthorize("@ss.hasPermi('sku:goodSku:export')")
    @Log(title = "goodSku", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, LiGoodsSku liGoodsSku)
    {
        List<LiGoodsSku> list = liGoodsSkuService.selectLiGoodsSkuList(liGoodsSku);
        ExcelUtil<LiGoodsSku> util = new ExcelUtil<LiGoodsSku>(LiGoodsSku.class);
        util.exportExcel(response, list, "goodSku数据");
    }

    /**
     * 获取goodSku详细信息
     */
    @ApiOperation("获取goodSku详细信息")
    @PreAuthorize("@ss.hasPermi('sku:goodSku:query')")
    @GetMapping(value = "/{id}")
    public ApiResult<LiGoodsSku> getInfo(@PathVariable("id") Long id)
    {
        return ApiResult.success(liGoodsSkuService.selectLiGoodsSkuById(id));
    }

    /**
     * 新增goodSku
     */
    @ApiOperation("新增goodSku")
    @PreAuthorize("@ss.hasPermi('sku:goodSku:add')")
    @Log(title = "goodSku", businessType = BusinessType.INSERT)
    @PostMapping
    public ApiResult add(@RequestBody LiGoodsSku liGoodsSku)
    {
        return ApiResult.success(liGoodsSkuService.insertLiGoodsSku(liGoodsSku));
    }

    /**
     * 修改goodSku
     */
    /*@ApiOperation("修改goodSku")
    @PreAuthorize("@ss.hasPermi('sku:goodSku:edit')")
    @Log(title = "goodSku", businessType = BusinessType.UPDATE)
    @PutMapping
    public ApiResult edit(@RequestBody LiGoodsSku liGoodsSku)
    {
        return ApiResult.success(liGoodsSkuService.updateLiGoodsSku(liGoodsSku));
    }*/

    /**
     * 删除goodSku
     */
    @ApiOperation("删除goodSku")
    @PreAuthorize("@ss.hasPermi('sku:goodSku:remove')")
    @Log(title = "goodSku", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public ApiResult remove(@PathVariable Long[] ids)
    {
        return ApiResult.success(liGoodsSkuService.deleteLiGoodsSkuByIds(ids));
    }
}
